package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import com.itheima.reggie.entity.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CategoryMapper {
    //分页查询
    List<Category> selectByPage(@Param("begin")Integer begin, @Param("pageSize") Integer pageSize);
    //总条数
    Integer count();
    //新增菜品分类
    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    Integer add(Category category);
    //修改
    @Update(("update category set type=#{type},name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}"))
    Integer update(Category category);
    //删除
    @Delete("delete from category where id=#{id}")
    Integer delete(Long id);
    //根据id查找菜品分类
    @Select("select * from category where id=#{id}")
    Category selectTypeById(Long id);
    //查询所有type=1的分类
    List<Category> selectAllByType(Integer type);
    //根据category_id查找
    @Select("select * from category where id=#{id}")
    Category selectByCategoryId(Long id);



}
